<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:useBean id="friend_add1" scope="session" class="software.Fri_done"/>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'friend_add_result.jsp' starting page</title>
   
  </head>
  <body>
     <% 
  String friendname=request.getParameter("Friendname");
  if(friend_add1.Fri_add_check(friendname)==0){
  out.print("<script>alert('该用户不存在!请重新添加 ');</script>");
  %>
  <script type="text/javascript">
        window.location.href="friend_add.jsp";    
   </script>
   <%
  }
  else{
  int Id=friend_add1.Fri_getid(friendname);
  String Id1=session.getAttribute("ID").toString();
  int Id2=Integer.parseInt(Id1);
 String con_Request=request.getParameter("con_Request");
  int flag=friend_add1.Fri_add(Id2,Id,con_Request);
  if(flag==0){
  out.print("<script>alert('已是你的好友!请重新添加');</script>");
  %>
  <script type="text/javascript">
        window.location.href="friend_add.jsp";    
   </script>
 <%
  }
  else if(flag==1){
  out.print("<script>alert('你已添加过该好友！请重新添加 ');</script>");
  %>
  <script type="text/javascript">
        window.location.href="friend_add.jsp";    
   </script>
 <%
  }
  else if(flag==2){
  out.print("<script>alert('添加成功！等待好友同意 ');</script>");
  %>
  <script type="text/javascript">
        window.location.href="selhome_main.jsp";    
   </script>
 <%
  } 
     }
   %>
  </body>
</html>
